#推理部分 其实就是用训练好的参数 再走一遍前向传输的过程，看输出的结果 识别到样本像哪个标签
import torch
import torch.nn.functional as F
from network import MLP


def main():
    net = MLP()
    net.load_state_dict(torch.load('models/MLP.pth'))

    torch.manual_seed(2)
    n_data = torch.ones(1, 2)
    x0 = torch.normal(1 * n_data, 1)
    # y0 = torch.zeros(1)
   
    net.eval()
    with torch.no_grad():
        outputs = net(x0)#前项
        print(F.softmax(outputs, dim=1))#前项计算出的p1 p2 p3
        predict = torch.max(outputs, dim=1)[1].numpy()
        print(predict)#预测出的结果 因为p1最大 p1对应的标签是0  所以这里输出0


if __name__ == '__main__':
    main()
